package com.chixing.day02;

import java.util.Arrays;
import java.util.HashSet;

public class HomeWork7_19 {
    public static void main(String[] args){

        int[] arr = {1, 1, 1, 1, 2, 3, 4, 3, 4, 1};
        for (int i =0;i<arr.length;i++){
            boolean flag =true;
            for (int j=0;j< arr.length;j++){
                if (arr[i]==arr[j]&&i!=j){
                    flag=false;
                    continue;
                }
            }
            if (flag){
                System.out.println("只出现一次的元素："+arr[i]);
            }
        }


        int[] nums={-1,0,1,2,-1,-4};
        Arrays.sort(nums);
        for (int i = 0; i < nums.length; i++) {
            for (int j = i+1; j < nums.length; j++) {
                for (int k = j+1; k < nums.length; k++) {
                    int a = nums[i];
                    int b = nums[j];
                    int c = nums[k];

                    if ( i > 0 && nums[i] == nums[ i - 1] ) continue;
                    if ( j > i + 1 && nums[j] == nums[ j - 1] ) continue;
                    if ( k > j + 1 && nums[k] == nums[ k - 1] ) continue;
                    if (a+b+c==0) {

                        System.out.println("[" + a + "," + b + "," + c + "]");
                    }

                }

            }

        }
        /**
         * 给定一个字符串数组 words，请计算当两个字符串 words[i] 和 words[j] 不包含相同字符时，
         * 它们长度的乘积的最大值。假设字符串中只包含英语的小写字母。如果没有不包含相同字符的一对字符串，
         * 返回 0。
         * 示例 1:
         *
         * 输入: words = ["abcw","baz","foo","bar","fxyz","abcdef"]
         * 输出: 16
         * 解释: 这两个单词为 "abcw", "fxyz"。它们不包含相同字符，且长度的乘积最大。
         * 示例 2:
         *
         * 输入: words = ["a","ab","abc","d","cd","bcd","abcd"]
         * 输出: 4
         * 解释: 这两个单词为 "ab", "cd"。
         * 示例 3:
         *
         * 输入: words = ["a","aa","aaa","aaaa"]
         * 输出: 0
         * 解释: 不存在这样的两个单词。
         */
        String[] Array2 = {"abcw","baz","foo","bar","fxyz","abcdef"};
        int longNumber = 0;
        int middleNumber;
        boolean flag = true;
        for (int i = 0;i < Array2.length;i++){
            for (int j = i + 1;j < Array2.length;j++){
                for (int i1 = 0;i1 < Array2[i].length();i1++){

                    for (int j1 = 0;j1 < Array2[j].length();j1++){
                        if (Array2[i].charAt(i1) == Array2[j].charAt(j1)) {
                            flag = false;
                            break;
                        }
                    }
                    if (!flag)
                        break;
                }
                if (flag){
                    middleNumber = Array2[i].length() * Array2[j].length();
                    if (middleNumber > longNumber)
                        longNumber = middleNumber;
                }
                flag = true;
            }
        }
        System.out.println("长度乘积最大值为：" + longNumber);






    }

}
